package IMIC.NGUYENVANTINH.ARRAYLIST.EXCERCISE.EX03;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Views {
	public static void main(String[] args) {
		List<StudentEntity> listArr = new ArrayList<StudentEntity>();
		Scanner sc = new Scanner(System.in);
		boolean flag = false;
		do {
			StudentEntity student = new StudentEntity();
			System.out.print("Nhap Fullname sv:");
			student.setFullName(sc.nextLine());
			System.out.print("Nhap Rollnumber: ");
			student.setRollNumber(sc.nextLine());
			System.out.print("Nhap Mark: ");
			student.setMark(sc.nextDouble());
			sc.nextLine();
			listArr.add(student);
			System.out.println("Ban muon nhap them sinh vien khong...");
			System.out.println("Nhap Y la co va N la khong....");

			String choise =  sc.nextLine();
			if (choise.toUpperCase().equals("N")) {
				flag = true;
			}

		} while (!flag);
		System.out.println("--------------------------------------");
		System.out.println("List Sinh vien vua nhap la...");
		PrintInfo(listArr);
		// Khoi tao controller
		Controllers controllers = new Controllers();
		// Uy quyen thuc thi nhiem vu
		// List sinh vien sau khi sap xep.
		System.out.println("--------------------------------------");
		System.out.println("List sinh vien sau khi sap xep...");
		controllers.SortStudent(listArr);
		PrintInfo(listArr);
	}
//Show data
	static void PrintInfo(List<StudentEntity> listArr) {
		for (int i = 0; i < listArr.size(); i++) {
			System.out.println("Ten sv thu " + (i + 1) + " " + listArr.get(i).getFullName());
			System.out.println("Ma sv thu " + (i + 1) + " " + listArr.get(i).getRollNumber());
			System.out.println("Diem sv thu " + (i + 1) + " " + listArr.get(i).getMark());
		}
	}

}
